//
//  StatusViewModel.m
//  OC-微博
//
//  Created by Apple on 15/11/13.
//  Copyright © 2015年 Apple. All rights reserved.
//

#import "StatusViewModel.h"
#import "Status.h"
#import "StatusListViewModel.h"
@interface StatusViewModel()
@property (nonatomic, strong) NSArray *aray;
@end
// 微博视图模型 - 处理单条微博的业务逻辑
@implementation StatusViewModel
/*
 // 用户会员图标
 @property (nonatomic, copy) UIImage *userMemberImage;
 /// 用户认证图标
 /// 认证类型，-1：没有认证，0，认证用户，2,3,5: 企业认证，220: 达人
 @property (nonatomic, copy) UIImage *userVipImage;
 */
#pragma mark /*******************  懒加载  *******************/
//- (void)setStatu:(Status *)statu {
//   
//    _statu = statu;
//    self.mbrank = statu.user.mbrank;
//    NSLog(@"%d",statu.user.mbrank);
//    NSLog(@"%d", self.mbrank);
//    NSLog(@"sds%d",statu.user.verified_type);
//}

#pragma mark /*******************  图标  *******************/
//用户会员图标
- (UIImage *)userMemberImage {
   
    // 根据 mbrank 来生成图像mb
    if(self.statu.user.mbrank > 0 && self.statu.user.mbrank < 7) {
        return [UIImage imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%d",self.statu.user.mbrank]];
    }
    return  nil;
}
- (void)setUserMemberImage:(UIImage *)userMemberImage {
        if(self.statu.user.mbrank > 0 && self.statu.user.mbrank < 7) {
    [UIImage imageNamed:[NSString stringWithFormat:@"common_icon_membership_level%d",self.statu.user.mbrank]];
          
        }


}
/// 用户认证图标
/// 认证类型，-1：没有认证，0，认证用户，2,3,5: 企业认证，220: 达人
- (UIImage *)userVipImage {
    switch (self.statu.user.verified_type) {
        case 0:
            return [UIImage imageNamed:@"avatar_vip"];
            break;
        case 2:
        case 3:
        case 5:
            return [UIImage imageNamed:@"avatar_enterprise_vip"];
            break;
        case 220:
            return [UIImage imageNamed:@"avatar_grassroot"];
            break;
        default:
            return nil;
            break;
    }
    
}
-(NSMutableArray *)thumbnailsURL {

        //根据模型生出 缩略图数组
        if (self.statu.pic_urls.count > 0) {
                       //创建数组
            _thumbnailsURL = [NSMutableArray array];
             //遍历字典数组
            for (NSDictionary *dict in self.statu.pic_urls) {
                 //字典根据key取值
                NSURL *url = [NSURL URLWithString:dict[@"thumbnail_pic"]];
                [_thumbnailsURL addObject:url];
               
            }
           
       }


    return  _thumbnailsURL;
}
- (instancetype)init:(Status *)status {

    StatusViewModel *v = [StatusViewModel new];
    v.statu = status;
    
//    //根据模型生出 缩略图数组
//    if (status.pic_urls.count > 0) {
//       
//        //创建数组
//        _thumbnailsURL = [NSMutableArray array];
//         //遍历字典数组
//        for (NSDictionary *dict in status.pic_urls) {
//             //字典根据key取值
//            NSURL *url = [NSURL URLWithString:dict[@"thumbnail_pic"]];
//            [_thumbnailsURL addObject:url];
//            
//        }
//    }
    
    return v;

}
@end
